<template>
  <div>
    <el-input class="w240" v-model="username"></el-input>
    <el-input class="w240" v-model="password"></el-input>
    <el-button type="primary" @click="login">登录</el-button>
    <el-button type="primary" @click="register">注册</el-button>
    <el-button @click="getUser">userinfo</el-button>
  </div>
</template>

<script>
import { ref } from 'vue'
import { useStore } from 'vuex'
export default {
  setup() {
    const store = useStore()
    const username = ref('')
    const password = ref('')
    const login = async () => {
      const res = await store.dispatch('_postLogin', { username: username.value, password: password.value })
    }
    const register = async () => {
      const res = await store.dispatch('_postRegister', { username: username.value, password: password.value })
    }
    const getUser = async () => {
      const res = await store.dispatch('_postUserDetail')
    }
    return { username, password, login, getUser, register }
  }
}
</script>

<style lang="scss" scoped>
</style>